<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>计算乘除法，输入两个数，按钮 1 计算乘法，按钮 2 计算除法</title>
</head>

<body>
  <input type="text" id="num1" /><br>
  <input type="text" id="num2" /><br>
  <button type="button" onclick="a('1')">乘</button>
  <button type="button" onclick="a('2')">除</button><br>
  <input type="text" id="outcome" />

  <script type="text/javascript">
    function a(e) {
      var num1 = parseInt(document.getElementById('num1').value);
      var num2 = parseInt(document.getElementById('num2').value);
      switch (e) {
        case '1':
          e = num1 * num2;
          break;
        case '2':
          e = num1 / num2;
          break;
      }
      document.getElementById('outcome').value = e;
    }
  </script>
</body>

</html>